//获取章节信息

import axios from "axios";
import { ElMessage } from "element-plus";
import { ref } from "vue";
import { getCurrentInstance } from "vue";

export async function historyRead(read_id, read_chapter,proxy) {
  console.log(read_id, read_chapter);
  const formData = new FormData();
  formData.append("read_id", read_id);
  formData.append("read_chapter", read_chapter);
  try {
    const response = await proxy.$http.post(
      "/api/book/update-read-chapter",
      formData,
      {
        headers: {
          "Content-Type": "multipart/form-data",
        },
      }
    );
    console.log(response);
    const res = response.data.data;
    console.log(res);
    const isSuccess = response.data.success;
    const message = response.data.message;
    if (isSuccess === false) {
      // ElMessage.error(message);
    } else {
      // ElMessage.success("添加历史记录成功");
      return true;
    }
  } catch (error) {
    // console.error(`Error fetching ${id} chapter:`, error);
    return [];
  }
}
